/*
 * Copyright 2008 CSC Consulting Group under the Apache License, 
 * Version 2.0 (the "License"); you may not use this file except in 
 * compliance with the License. You may obtain a copy of the License at 
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
 * law or agreed to in writing, software distributed under the License is 
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific language 
 * governing permissions and limitations under the License.
 */
package com.waw.memberMap.plugin;

import com.jivesoftware.base.plugin.*;
import com.jivesoftware.base.Log;
import com.jivesoftware.community.event.ProfileEventDispatcher;

/**
 * MemberMapPlugin registers a ProfileListener which calculates a user's geolocation 
 * based on the address the user enters in their profile.
 */
public class MemberMapPlugin implements Plugin<MemberMapPlugin> {
	UserProfileListener profileListener = new UserProfileListener();

	/**
	 * Plugin destroy lifecycle method - remove the user profile listener.
	 */
    public void destroyPlugin() {
    	ProfileEventDispatcher.getInstance().removeListener(profileListener);
        Log.info("Member Map Plugin - exiting.");
    }

	/**
	 * Plugin initiatize lifecycle method - add the user profile listener.
	 * 
	 * @param manager The plugin manager
	 * @param pluginData Information about the plugin.
	 */	
	public void initializePlugin(PluginManager manager, PluginMetaData pluginData) {
        Log.info("Member Map Plugin - initiatizing.");
        ProfileEventDispatcher.getInstance().addListener(profileListener);
	}
}
